// import { cn } from "@/utils";
// import type { ButtonProps } from "antd";
// import type { CSSProperties, ReactNode } from "react";
//
// type Props = {
// 	children: ReactNode;
// 	className?: string;
// 	style?: CSSProperties;
// } & ButtonProps;
//
//
// export default function IconButton({
// 	children,
// 	className,
// 	style,
// 	onClick,
// }: Props) {
// 	return (
// 		<button
// 			type="button"
// 			style={style}
// 			className={cn(
// 				"flex cursor-pointer items-center justify-center rounded-full p-2 hover:bg-hover",
// 				className,
// 			)}
// 			onClick={onClick}
// 		>
// 			{children}
// 		</button>
// 	);
// }
import React, { forwardRef } from "react";
import type { ButtonProps } from "antd";
import { Button } from "antd";

type SizeType = ButtonProps['size']; // 获取 AntD 的原始 size 类型

interface IconButtonProps extends Omit<ButtonProps, 'size'> {
	icon?: React.ReactNode;
	iconSize?: string | number; // 将 size 重命名为 iconSize 避免冲突
}

const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
	({ className = "", icon, iconSize, children, ...props }, ref) => {
		return (
			<Button
				ref={ref}
				className={`flex items-center justify-center ${className}`}
				{...props}
			>
				{icon && React.cloneElement(icon as React.ReactElement, {
					size: iconSize // 单独控制图标大小
				})}
				{children}
			</Button>
		);
	}
);

IconButton.displayName = "IconButton";

export default IconButton;
